Avoid excess notification for GdkCellRendererPixbuf::icon-size
authorMatthias Clasen <mclasen@redhat.com>
Wed, 27 Dec 2017 01:03:19 +0000 (20:03 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 27 Dec 2017 01:06:06 +0000 (20:06 -0500)
We have a test that checks this, and it is right thing to do.

gtk/gtkcellrendererpixbuf.c

index d6a610c0a35c7629a8de0ed754b7b5fc9761cb6f..b438ddc5c361cf3721a0a06cc41e91e37a20e1de 100644 (file)
@@ -198,7 +198,7 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
                                                      P_("The GtkIconSize value that specifies the size of the rendered icon"),
                                                       GTK_TYPE_ICON_SIZE,
                                                      GTK_ICON_SIZE_INHERIT,
-                                                     GTK_PARAM_READWRITE));
+                                                     GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
 
   /**
    * GtkCellRendererPixbuf:icon-name:
@@ -336,6 +336,19 @@ take_image_definition (GtkCellRendererPixbuf *cellpixbuf,
   priv->image_def = def;
 }
 
+static void
+gtk_cell_renderer_pixbuf_set_icon_size (GtkCellRendererPixbuf *cellpixbuf,
+                                        GtkIconSize            icon_size)
+{
+  GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv;
+
+  if (priv->icon_size == icon_size)
+    return;
+
+  priv->icon_size = icon_size;
+  g_object_notify (G_OBJECT (cellpixbuf), "icon-size");
+}
+
 static void
 gtk_cell_renderer_pixbuf_set_property (GObject      *object,
                                       guint         param_id,
@@ -373,7 +386,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject      *object,
       take_image_definition (cellpixbuf, gtk_image_definition_new_texture (g_value_get_object (value)));
       break;
     case PROP_ICON_SIZE:
-      priv->icon_size = g_value_get_enum (value);
+      gtk_cell_renderer_pixbuf_set_icon_size (cellpixbuf, g_value_get_enum (value));
       break;
     case PROP_ICON_NAME:
       take_image_definition (cellpixbuf, gtk_image_definition_new_icon_name (g_value_get_string (value)));